<template>
  <div class="Seller">
    <!-- 店铺图片 -->
    <div class="sellerImg">
      <van-image :src="data.shopLogo" class="img" fit="contain" round />
      <!-- 店铺名字 -->
      <span>{{ data.name }}</span>
    </div>
    <!-- 详细信息 -->
    <div class="details">
      <div class="left d-flex">
        <div class="d-flexs mr-1">
          <span>{{ num }}</span>
          <span>总销量</span>
        </div>
        <div class="d-flexs">
          <span>{{ data.cGoods }}</span>
          <span>全部宝贝</span>
        </div>
      </div>
      <!-- 描述信息 -->
      <div class="right">
        <div v-for="item in data.score" :key="item">
          <p class="mr-1">{{ item.name }}</p>
          <span
            :class="!item.isBetter ? 'active' : 'active-false'"
            style="width: 40px"
            >{{ item.score }}</span
          >
          <span
            :class="!item.isBetter ? 'active-low' : 'active-height'"
            v-if="item.isBetter"
            >高</span
          >
          <span
            :class="!item.isBetter ? 'active-low' : 'active-height'"
            class=""
            v-else
            >低</span
          >
        </div>
      </div>
    </div>
      <!-- 按钮 -->
    <div class="d-flex justify-center">
      <van-button class="btn" round type="primary">进店逛逛</van-button>
    </div>
  </div>
</template>

<script setup="props">
import { defineProps, computed } from "vue";
const props = defineProps({
  data: {
    type: Object,
    default: () => {},
  },
});
// 计算属性
const num = computed(() => {
  return props.data.cSells > 10000
    ? (props.data.cSells / 10000).toFixed(1) + "万"
    : props.data.cSells + "万";
});
</script>

<style scoped lang="scss">
.Seller {
  border-top: 7px solid #f2f5f8;
  border-bottom: 7px solid #f2f5f8;
  margin-top: 8px;
  padding: 0 10px;
}
.sellerImg {
  width: 100%;
  display: flex;
  height: 40px;
  align-items: center;
  margin-top: 20px;
  .img {
    border: 1px solid #dadada;
    margin-right: 10px;
    width: 50px;
    height: 50px;
  }
  span {
    font-size: 16px;
    color: #666666;
  }
}
// 详细信息
.details {
  display: flex;
  align-items: center;
  justify-content: center;
}
.left {
  border-right: 1px solid rgba(0, 0, 0, 0.1);
  padding-right: 20px;
  font-size: 15px;
}
.right {
  font-size: 12px;
  margin-left: 20px;
  > div {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
  }
  p {
    white-space: nowrap;
  }
}
.active {
  color: #5ea732;
}
.active-false {
  color: #f13e3a;
}
.active-low {
  background-color: #5ea732;
  color: white;
}
.active-height {
  background-color: #f13e3a;
  color: white;
}
.btn {
  background-color: #f2f5f8;
  color: #666;
  width: 160px;
  height: 30px;
  border: none;
  margin-top: 10px;
  margin-bottom: 30px;
}
</style>